package com.chat.business.controller;

import com.chat.business.service.ISyncService;
import com.chat.business.service.IUserService;
import com.chat.common.vo.R;
import com.chat.common.vo.SyncUserDataVO;
import com.chat.common.vo.UserVo;
import jakarta.validation.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户信息修改
 */
@RestController
@RequestMapping("/business/user")
public class UserController {

    @Autowired
    IUserService userService;
    @Autowired
    ISyncService syncService;

    /**
     * 更新用户个人信息
     * @param userVo
     * @return
     */
    @PostMapping("/updateInfo")
    public R<UserVo> updateInfo(@RequestBody UserVo userVo){
        return userService.updateInfo(userVo);
    }

    /**
     * 每次登陆后同步个人数据
     */
    @GetMapping("/sync")
    public R<SyncUserDataVO> sync(){
       return syncService.sync();
    }

    /**
     * 下线
     * @return
     */
    @GetMapping("/offline")
    public R offline(@RequestParam @NotBlank(message = "ID不能为空") String ID) {
        return userService.offline(ID);
    }
}
